/**
 * 
 */
package org.vsg.stock.basic.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.vsg.common.biz.exception.ServiceException;
import org.vsg.stock.basic.persistence.VolFigureKlineDailyDao;
import org.vsg.stock.basic.service.VolLineBusinessService;
import org.vsg.stock.basic.service.indicator.processor.HorizontalFocusLineProcessor;
import org.vsg.stock.basic.service.indicator.processor.PitchedFocusLineProcessor;
import org.vsg.stock.basic.service.indicator.processor.PoleLineProcessor;
import org.vsg.stock.core.domain.StockDailyKLine;
import org.vsg.stock.core.indicator.coordinate.Coordinate;
import org.vsg.stock.core.indicator.coordinate.CoordinateConfiguration;
import org.vsg.stock.core.indicator.coordinate.CoordinateFactory;
import org.vsg.stock.core.indicator.coordinate.OriginalDataPoint;
import org.vsg.stock.core.persistence.StockDailyKLineDao;
import org.vsg.stock.core.persistence.StockInfoDao;
import org.vsg.stock.core.utils.StockDateUtilExtension;

/**
 * @author Bill Vison
 *
 */
public class VolLineBusinessServiceImpl implements VolLineBusinessService {

	@Resource
	private VolFigureKlineDailyDao volFigureKlineDailyDao;
	
	@Resource
	private StockDailyKLineDao stockDailyKLineDao;
	
	@Resource
	private StockInfoDao stockInfoDao;
	
	@Autowired
	private StockDateUtilExtension stkDateUtilExtension;
	
	@Autowired
	private CoordinateFactory coordinateFactory;	
	
	
	/* (non-Javadoc)
	 * @see org.vsg.stock.basic.service.VolLineBusinessService#findVolLineByPoint(org.vsg.stock.core.indicator.coordinate.OriginPoint, org.vsg.stock.core.indicator.coordinate.OriginPoint, org.vsg.stock.core.indicator.coordinate.CoordinateConfiguration)
	 */
	@Override
	public void findVolLineByStockPoints(String stockCode ,
			Date fromDate , Date toDate,
			OriginalDataPoint point1, OriginalDataPoint point2,
			CoordinateConfiguration config) throws ServiceException {

		Coordinate coordinate = coordinateFactory.
			createCoordinateInstance(stockCode, config , stkDateUtilExtension);
	
		
		PoleLineProcessor plProc = new PoleLineProcessor();
		plProc.setStartPoint( point1 );
		plProc.setEndPoint(point2);

		//coordinate.addProcessor(plProc);

		//PitchedFocusLineProcessor focusProc = new PitchedFocusLineProcessor();
		//coordinate.addProcessor(focusProc);


		
		// --- read data list object ---
		List<StockDailyKLine> listKLineStkList = stockDailyKLineDao.findStockLineByCycle(stockCode, fromDate, toDate);
	
		coordinate.process( listKLineStkList );
		
	}


	@Override
	public void findVolLineByStockPoints(String stockCode, Date fromDate,
			Date toDate, CoordinateConfiguration config)
			throws ServiceException {


		Coordinate coordinate = coordinateFactory.
			createCoordinateInstance(stockCode, config , stkDateUtilExtension);
	

		HorizontalFocusLineProcessor focusProc2 = new HorizontalFocusLineProcessor();
		coordinate.addProcessor(focusProc2);		
				
		/*
		PitchedFocusLineProcessor focusProc = new PitchedFocusLineProcessor();
		coordinate.addProcessor(focusProc);
		*/
	
		// --- read data list object ---
		List<StockDailyKLine> listKLineStkList = stockDailyKLineDao.findStockLineByCycle(stockCode, fromDate, toDate);
	
		coordinate.process( listKLineStkList );

		
	}

	
	
}
